import SwiftUI

struct SearchCard: View {
    var item:MainPica = mainpicas[0]
 
    
    var body: some View {
      
            HStack{
                CachedImageView(imageURL: item.cover)
      
                    .scaledToFill()
                    .clipped()
                    .frame(width: 70, height: 70)
                    .clipShape(Circle())
                VStack{
                    HStack {
                        Text(item.name)
                            .font(.system(size: 20))
                            .foregroundStyle(.white)
                            .lineLimit(1)
                        Spacer()
                    }
                    HStack {
                        ForEach(item.tags.prefix(3), id: \.self) { tag in
                            Text(tag)
                                .font(.system(size: 14))
                                .foregroundStyle(.white)
                                .padding(6)
                                .background(Color.white.opacity(0.2))  // 背景色
                                .clipShape(RoundedRectangle(cornerRadius: 6))  // 圆角
                                .overlay(
                                    RoundedRectangle(cornerRadius: 6)  // 边框的圆角
                                        .stroke(Color.gray, lineWidth: 1)  // 灰色边框
                                )
                                .padding(.trailing, 2)  // 每个标签之间有一些间距
                        }
                        Spacer()
                    }
                    
                }
                .padding(.leading,20)
                
            }.padding(10)
   
     
    }
}

#Preview {
    SearchCard()
        .background(Color("BgColor1"))
}
